home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 151-175 / disk_172 / spiff / floatrep.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  67 lines

  1. /*                        Copyright (c) 1988 Bellcore
  2. **                            All Rights Reserved
  3. **       Permission is granted to copy or use this program, EXCEPT that it
  4. **       may not be sold for profit, the copyright notice must be reproduced
  5. **       on copies, and credit should be given to Bellcore where it is due.
  6. **       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7. */
  8.  
  9. /*
  10. ** header file that defines canonical floating point structure
  11. **    and routines
  12. */
  13.  
  14.  
  15. #ifndef  R_INCLUDED
  16.  
  17. /*
  18. **    when evaluated to a string, the fractional part will
  19. **        not exceed this length
  20. */
  21. #define R_MANMAX    200
  22.  
  23. #define R_POSITIVE    0
  24. #define R_NEGATIVE    1
  25.  
  26. struct  R_flstr {
  27.     int exponent;
  28.     int man_sign;
  29.     char *mantissa;
  30. };
  31.  
  32. typedef struct R_flstr *R_float;
  33.  
  34. #define R_getfrac(x)    (x->mantissa)
  35.  
  36. extern R_float R_makefloat();
  37.  
  38. extern int R_getexp();
  39.  
  40. #define R_getsign(x)    (x->man_sign)
  41.  
  42. /*
  43. **    takes a string
  44. */
  45. #define R_setfrac(x,y)    ((void)strcpy(x->mantissa,y))
  46. /*
  47. **    takes an int
  48. */
  49. #define R_setexp(x,y)    (x->exponent = y)
  50. /*
  51. **    takes a sign
  52. */
  53. #define R_setsign(x,y)    (x->man_sign = y)
  54.  
  55. /*
  56. #define R_incexp(x)    ((x->exponent)++)
  57. #define R_decexp(x)    ((x->exponent)--)
  58. */
  59.  
  60. #define R_setzero(x)    R_setfrac(x,"0");R_setexp(x,0);R_setsign(x,R_POSITIVE)
  61.  
  62. #define R_zerofloat(x)    ((0 == x->exponent) && (!strcmp(x->mantissa,"0")))
  63.  
  64. #define R_INCLUDED
  65.  
  66. #endif
  67.